package wqh.dao.impl;

import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;
import wqh.dao.XkSensorAlarmDao;
import wqh.domain.XkSensorAlarm;

/**
 * Created by devts on 2017/1/5.
 */
@Repository("xkSensorAlarmDao")
public class XkSensorAlarmDaoImpl extends DaoImpl<XkSensorAlarm> implements XkSensorAlarmDao {


    @Override
    public void deleteBySensorIdAndDeviceId(XkSensorAlarm x) {
        Session session = this.getSessionFactory().getCurrentSession();
        String hql = "DELETE FROM XkSensorAlarm as x WHERE x.device_id = :device_id AND sensor_id = :sensor_id";
        Query query = session.createQuery(hql);
        query.setParameter("device_id",x.getDevice_id());
        query.setParameter("sensor_id",x.getSensor_id());
        query.executeUpdate();
    }
}
